import com.sun.org.apache.regexp.internal.RE;

import java.util.HashSet;

/**
 * Created whit IntelliJ IDEA.
 * Description：
 * User：ZHONGCHEN
 * Date:2022-04-10
 * Time:10:51
 */
//804. 唯一摩尔斯密码词-简单模拟
public class TestDemo {
    public int uniqueMorseRepresentations(String[] words) {
        String[] ss = new String[]{".-", "-...", "-.-.", "-..", ".",
                "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--",
                "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-",
                ".--", "-..-", "-.--", "--.."};

        HashSet<String> set = new HashSet<>();
        for (String s : words) {
            StringBuilder stringBuilder = new StringBuilder();
            for (char c: s.toCharArray()) {
                stringBuilder.append(ss[c-'a']);
            }
            set.add(stringBuilder.toString());
        }
        return set.size();
    }
}
